﻿<div style="width: 380px; height: 350px;">
    <div class="modal-header">
        <a class="close" href="javascript:$.fancybox.close();">×</a>
        <h3>
            邮箱绑定</h3>
    </div>
    <div style="padding: 15px;">
        <div class="input-append">
            <input class="span3" type="text" id="email" name="email" placeholder="请输入您有效的电子邮箱">
            <button class="btn" type="button" onclick="emailBinding();">
                绑定该邮箱</button>
        </div>
        <p id="help-binding" class="help-block">
            如：example@@silenthink.com
        </p>
        <div id=""></div>
        <p>
            此链接将在<span>30</span>分钟后失效，失效后请重新填写信息
        </p>
        <p>
            <a target="_blank">登录邮箱</a>完成账号激活 <span><a href="javascript:void(0);" onclick="reReg()">
                换个邮箱注册</a></span>
        </p>
        <p class="mail-resend">
            还没收到邮件？<a id="resendemail" class="btn disabled" href="javascript:void(0);">重新发送</a>
            <span id="resendtimer">120</span>
        </p>
    </div>
</div>
<script type="text/javascript">
    function emailBinding() {
        var email = $('#email').val();
        if (email.isEmail()) {
            var url = '/security/emailbinding';
            $.postJSON(url, { email: email }, function (result) {
                if (result.Status == true) {
                    $("#help-binding").html('');
                }
                else {
                    $("#help-binding").html(result.Message);
                }
            });
        }
        else {
            $("#help-binding").html('请输入正确的邮箱！如：example@silenthink.com');
        }
    }
    function emailSuffixSource(query, process) {
        var val = query;
        if (val.indexOf('@@') >= 0) {
            val = val.substring(0, val.indexOf('@@'));
        }
        var availableTags = [val + "@@qq.com", val + "@@163.com", val + "@@sina.com", val + "@@sohu.com", val + "@@yahoo.cn", val + "@@gmail.com", val + "@@hotmail.com"];
        return availableTags;
    }
    $(function () {
        $('#email').typeahead({ source: emailSuffixSource });
    });
</script>
